import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

import {postRequest} from "@/utils/config";
import {KeyValuePostRequest} from "@/utils/config";
import {getRequest} from "@/utils/config";
import {putRequest} from "@/utils/config";
import {deleteRequest} from "@/utils/config";
import {initMenus} from "@/utils/menus";
import 'font-awesome/css/font-awesome.css'

Vue.prototype.KeyValuePostRequest = KeyValuePostRequest;
Vue.prototype.postRequest = postRequest;
Vue.prototype.getRequest = getRequest;
Vue.prototype.putRequest = putRequest;
Vue.prototype.deleteRequest = deleteRequest;


Vue.config.productionTip = false

router.beforeEach((to, from, next) => {
  if (to.path == '/'){
    next();
  }else {
    if (window.sessionStorage.getItem("user")) {
      initMenus(router,store);
      next();
    } else {
      next('/?redirect=' + to.path);
    }

  }
})


Vue.use(ElementUI);
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
